exports.invite_list = function(req,res) {

    //获取restful参数
    var restfulParams = req.routeInfo.restfulParams;

    var resultData = {};

    var skip  = restfulParams.skip  == undefined ? 0 : restfulParams.skip;
    var limit = restfulParams.limit == undefined ? config.publicConfig.LIMIT : restfulParams.limit;

    //任务流创建
    async.waterfall([

            //获取机构列表
            function(cb){

                R.SEND_HTTP(
                    req,
                    {
                        url    : CORE_APIConfig.coreAPI.searchOrganization + "/skip/" + skip + "/limit/" + limit,
                        method : 'POST',
                        data   : {
                            fields : [
                                "o_id",
                                "o_name",
                                "o_desc",
                                "o_logo",
                                "o_invite_count"
                            ].join(",")
                        }
                    },
                    function (err, data) {

                        resultData.organizationData = data.data;

                        cb();
                    }
                );
                
            },

            //获取是否邀请过该机构了
            function(cb){
                
                var tasks = [];

                //循环节点列表
                resultData.organizationData.forEach(function (item, i) {

                    //创建每一个插入任务
                    tasks.push(function (cb) {

                        R.SEND_HTTP(
                            req,
                            {
                                url    : CORE_APIConfig.coreAPI.search_invite_log + "/fil_fcid/" + restfulParams.fc_id + "/fil_uid/" + restfulParams.u_id + "/fil_invite_type/0/fil_fid/" + item.o_id,
                                method : 'POST',
                                data   : {
                                    fields : "fil_id"
                                }
                            },
                            function (err, data) {

                                if(data.data.length > 0){
                                    item.isInvite = true;
                                }else{
                                    item.isInvite = false;
                                }
                           
                                cb();
                            }
                        );
                    });

                });

                async.waterfall(tasks, cb);

            }

          
        ],function(err, result){

            //返回最终拼接结果
            RES.response(res,true,resultData);

        });
}